#include <stdio.h>

//测试运算符使用。

int main(int argc,char *argv[])
{
	/*  //+
	int a = 10;
	int b = 20;
	int c = a + b;
	printf("c = %d\n",c);
	
	float d = 3.14;
	c = a + d;//c = 10 + 3.14 = 13.14
	          //记住：将浮点型数据赋值给整型变量，精度会降低（小数点后的数字都没了）
	printf("c = %d\n",c);
	//printf("c = %f\n",c);这样不行，一个c是int类型
	
	//-
	int e = b - a;
	printf("e = %d\n",e);
	
	e = b - d;
	printf("e = %d\n",e);
	
	float f = b - d;//20 - 3.14 = 16.86
					//将浮点型数据赋值给浮点型变量，精度不会降低。
	printf("f = %f\n",f);//16.860001
	
	//*
	int g = a * b;
	printf("g = %d\n",g);
	
	//  /
	int h = 5/2; //5除以2，结果是2，再把2赋值给h，所以答案是2
	printf("h = %d\n",h); //2
	
	h = 5.0/2;  //5.0除以2，结果是2.5，再把2.5赋值给h，精度就会降低，h=2
	printf("h = %d\n",h); //2
	
	h = 5/2.0;  //5除以2.0，结果是2.5，再把2.5赋值给h，精度就会降低，h=2
	printf("h = %d\n",h); //2
	
	h = 5.0/2.0;  //5.0除以2.0，结果是2.5，再把2.5赋值给h，精度就会降低，h=2
	printf("h = %d\n",h); //2
	
	float k;
	k = 5/2;//5除以2，结果是2，再把2赋值给k，由于k是浮点型的数据，所以k=2.000000
	printf("k = %f\n",k); //2.000000
	
	k = 5.0/2;//5.0除以2，结果是2.5，再把2.5赋值给k，所以k=2.500000
	printf("k = %f\n",k); //2.500000
	
	k = 5/2.0;//5除以2.0，结果是2.5，再把2.5赋值给k，所以k=2.500000
	printf("k = %f\n",k); //2.500000
	
	k = 5.0/2.0;//5.0除以2.0，结果是2.5，再把2.5赋值给k，所以k=2.500000
	printf("k = %f\n",k); //2.500000
	*/
	
	/*//%  求余数 
	int a = 10;
	int b = 3;
	
	int c = a % b;
	printf("c = %d\n",c); */
	/*  注意：求余数2个数不能有小数点
	c = 10.0 % 3;
	printf("c = %d\n",c); //编译出错
	
	c = 10 % 3.0;
	printf("c = %d\n",c);//编译出错
	
	c = 10.0 % 3.0;
	printf("c = %d\n",c);//编译出错
	*/
	/*
	//赋值运算
	int a = 10;// = 把右边的值赋值给左边的变量。
	
	//if(a == 10)//判断a是否等于10
	
	//if(a != 10)//判断a是否不等于10
	
	a += 2; //a = a + 2
	printf("a = %d\n",a);//12
	
	a -= 2; //a = a - 2
	printf("a = %d\n",a);//10
	
	a *= 2;//a = a * 2
	printf("a = %d\n",a);//20
	
	a /= 2;//a = a / 2
	printf("a = %d\n",a);//10
	*/
	/*
	//逻辑运算
	//&位与  &&逻辑与  |位或  ||逻辑或
	//与：两个条件都必须满足，才为真
	//或：只要有一个条件满足，就为真
	int a = 5 & 6;
	printf("a= %d\n",a);
	
	a = 5 && 0;
	printf("a= %d\n",a);//0
	
	a = 5 | 6;
	printf("a= %d\n",a);
	
	a = 5 || 0;
	printf("a= %d\n",a);//1
	*/
	
	//++自增
	//--自减
	
	/*int a =10;
	a++;
	printf("a = %d\n",a);//11
	*/
	/*
	int a = 10;
	++a;
	printf("a = %d\n",a);//11
	*/
	/*
	int a = 10;
	int b = 10 * a++;//先b = 10 * 10，再a = 11
	printf("b = %d\n",b);//100
	*/
	/*
	int a = 10;
	int b = ++a *10;//先a = 11，再b = 11 * 10
	printf("b = %d\n",b);//110
	*/
	
	int a = 10;
	printf("a = %d\n",a++);//10
	printf("a = %d\n",a);//11
	printf("a = %d\n",++a);//12
	printf("a = %d\n",a);//12
	
	printf("a = %d\n",a--);//12
	printf("a = %d\n",a);//11
	printf("a = %d\n",--a);//10
	printf("a = %d\n",a);//10
	
	
	
	return 0;
}